package 正则表达式;

public class 字符类 {
    public static void main(String[] args) {
        System.out.println("a".matches("[abc]"));
        System.out.println("z".matches("[abc]"));
        System.out.println("ab".matches("[abc][abc]"));

        System.out.println("------------------------------------------------------------");

        System.out.println("a".matches("[^abc]"));
        System.out.println("z".matches("[^abc]"));
        System.out.println("zz".matches("[^abc]"));
        System.out.println("zz".matches("[^abc][^abc]"));

        System.out.println("------------------------------------------------------------");

        System.out.println("a".matches("[a-d[m-p]]"));
        System.out.println("e".matches("[a-d[m-p]]"));

        System.out.println("------------------------------------------------------------");

        //a到z与[def]的交集=def
        System.out.println("a".matches("[a-z&&[def]]"));
        System.out.println("e".matches("[a-z&&[def]]"));

        System.out.println("------------------------------------------------------------");

        //[ad-z]
        System.out.println("a".matches("[a-z&&[^bc]]"));
        System.out.println("c".matches("[a-z&&[^bc]]"));

        System.out.println("------------------------------------------------------------");

        //[a-lq-z]
        System.out.println("a".matches("[a-z&&[^m-p]]"));
        System.out.println("n".matches("[a-z&&[^m-p]]"));
    }
}
